package reflaction;

/**
 * @author cyt
 * @create 2020-04-13 16:06
 */
public class Test04 {
    static {
        System.out.println("加载Main");
    }

    public static void main(String[] args) throws ClassNotFoundException {
        // 主动引用
        // B b = new B();
        // Class.forName("Reflaction.B");
        // 不会产生子类的引用
        // System.out.println(B.n);
        // System.out.println(B.m);
        // 什么都不引用
        B[] arr = new B[5];
    }
}

class A {
    static int n = 10;

    static {
        System.out.println("父类的静态代码加载");
    }

    public A() {
        System.out.println("加载父类");
    }
}

class B extends A {
    static final int m = 100;

    static {
        System.out.println("子类的静态代码加载");
    }

    public B() {
        System.out.println("加载子类");
    }
}
